<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div id="app">
    <button onclick="del()">删除</button>
</div>

<script>
    //document.cookie = 'dl=abc;';

    window.onbeforeunload = function(e) {
        del()
    }
    function del(){
        console.log(111)
        var date = new Date();
        date.setDate(date.getDate() - 1);//访问页面的前一天
        document.cookie = "dl='';expires="+date.toString();
    }


</script>
</body>
</html>
